package com.ksjourney;

import mars.game.core.Config;
import mars.game.core.Sprite;

public class Enemy extends Sprite
{
	private static final int ENEMEYLIFE = 1;
	private static final int ANIMATION_LENGTH = 4;
	public static final int ENEMY1 = R.drawable.img_enemy;
	public static final int ENEMY2 = R.drawable.img_enemy1;
	public static final int ENEMY3 = R.drawable.img_enemy2;
	public static final int ENEMY4 = R.drawable.img_enemy3;
	
	public static final int[] ENEMY_APPE =	{ ENEMY1,ENEMY2,ENEMY3,ENEMY4};
	
	public static final int[] ANIMATION_NOMAL =	{0,1};
	
	public static final int[] ANIMATION_BREAK =
	{ 0, 1, 2 };
	
	public static final int[] ANIMATION_SELECT =
	{ 0, 3 };
	
	public static final int NOMAL = 0;
	
	public static final int BREAK = 1;
	
	public static final int SELECT = 2;
	
	public static final int DISAPPEAR = 3;
	
	public Enemy(int resId)
	{

		super(ANIMATION_LENGTH, resId);
		this.state = NOMAL;
	}
	
	public static Enemy markEnemy()
	{

		int random = (int) (Math.random() * ANIMATION_LENGTH);
		int color = ENEMY_APPE[random];
		Enemy enemy = new Enemy(color);
		int x = (int) (Math.random() * Config.SCREEN_WIDTH);
		int y = (int) (Math.random() * Config.SCREEN_HEIGHT);
		enemy.setPos(x, y);
		enemy.setSpeed(-3, -2);
		enemy.setLife(ENEMEYLIFE);
		return enemy;
	}
	
	@Override
	public void tick()
	{
		super.tick();
		switch (state)
		{
			case NOMAL:
				this.mAniIndex = ENEMY_APPE [mCounts % ENEMY_APPE.length];
				break;
			case BREAK:
				this.mAniIndex = ANIMATION_BREAK [mCounts % ANIMATION_BREAK.length];
				break;
			case SELECT:

				break;
			case DISAPPEAR:

				break;
			
			default:
				break;
		}
		
	}
	
	
	
}
